package initialize

import (
	"github.com/gin-gonic/gin"
	"github.com/swaggo/gin-swagger"
	swaggerFiles "github.com/swaggo/files" // swagger embed files
	"net/http"
	_ "teacher-helper/docs"
	"teacher-helper/middleware"
	"teacher-helper/routers"
)

func SetupRouters() (Router *gin.Engine) {
	Router = gin.Default()
	Router.Static("/static", "static")
	Router.LoadHTMLGlob("templates/*")
	Router.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.html", nil)
	})

	Router.Use(middleware.Cors())
	url := ginSwagger.URL("http://localhost:8000/swagger/doc.json") // The url pointing to API definition
	Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
	ApiV1Group := Router.Group("api/v1")

	routers.InitBaseRouter(ApiV1Group)
	routers.InitUserRouter(ApiV1Group)
	routers.InitMenuRouter(ApiV1Group)
	routers.InitRoleRouter(ApiV1Group)
	routers.InitDepartRouter(ApiV1Group)
	routers.InitMajorRouter(ApiV1Group)
	routers.InitSemesterRouter(ApiV1Group)
	routers.InitClassRouter(ApiV1Group)
	routers.InitGradeRouter(ApiV1Group)
	routers.InitStudentRouter(ApiV1Group)
	routers.InitScoreRouter(ApiV1Group)
	routers.InitCourseRouter(ApiV1Group)
	routers.InitActivityRouter(ApiV1Group)
	routers.InitPoliticalRouter(ApiV1Group)
	routers.InitStuGrantRouter(ApiV1Group)
	routers.InitGrantRouter(ApiV1Group)
	routers.InitRewardRouter(ApiV1Group)
	routers.InitStuRewardRouter(ApiV1Group)
	routers.InitJobRouter(ApiV1Group)
	routers.InitPartyRouter(ApiV1Group)
	routers.InitMessageRouter(ApiV1Group)

	return
}